package com.rop.znyx.sys.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rop.znyx.common.result.Result;
import com.rop.znyx.model.sys.RegionWare;
import com.rop.znyx.sys.mapper.RegionWareMapper;
import com.rop.znyx.sys.service.RegionWareService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA
 * User: Rop
 * Date: 2023/7/19
 * Time: 10:09
 * Description:
 */

@RestController
@RequestMapping("api/sys/inner")
@RequiredArgsConstructor
public class RegionInnerController {

    private final RegionWareService regionWareService;

    @ApiOperation("根据区域id获取仓库id")
    @GetMapping("getWareId/{regionId}")
    public Result<Long> getWareId(@PathVariable("regionId") Long regionId){
        RegionWare regionWare = regionWareService.getBaseMapper().selectOne(new LambdaQueryWrapper<RegionWare>().eq(RegionWare::getRegionId, regionId));
        return Result.ok(regionWare.getWareId());
    }
}
